#include "BoundingBox.h"
using namespace std;

BoundingBox::BoundingBox()
{
	reset();
}

void BoundingBox::update(point4 point)
{
	if(isInit==false)
	{
		_max = point3(point.x,point.y,point.z);
		_min = point3(point.x,point.y,point.z);
		isInit = true;
	}
	else
	{
		if(point.x > _max.x){_max.x = point.x;}
		if(point.y > _max.y){_max.y = point.y;}
		if(point.z > _max.z){_max.z = point.z;}
		if(point.x < _min.x){_min.x = point.x;}
		if(point.y < _min.y){_min.y = point.y;}
		if(point.z < _min.z){_min.z = point.z;}
	}
}

void BoundingBox::reset()
{
	_max = point3(0.0f,0.0f,0.0f);
	_min = point3(0.0f,0.0f,0.0f);
	isInit = false;

}

point3 BoundingBox::getRange()
{
	point3 range = _max - _min;
	return range;
}

point3 BoundingBox::getMax()
{
	return _max;
}

point3 BoundingBox::getMin()
{
	return _min;
}

point4 BoundingBox::getCenter()
{
	point4 center = point4((_max.x+_min.x)/2.0f,(_max.y+_min.y)/2.0f,(_max.z+_min.z)/2.0f,1.0f);
	return center;
}

void BoundingBox::setMax(point3 max)
{
	_max = max;
}

void BoundingBox::setMin(point3 min)
{
	_min = min;
}

